<?php
if( ! defined('BASEPATH')) exit('No direct script access allowed');

class User extends CI_Controller
{


	function __construct()
	{
		parent::__construct();
		// check if user logged in
		if(!$this->ion_auth->logged_in()){
			redirect('auth/login');
		}
		$this->load->model('user/user_model');
		$this->load->model('user/about_model');
		$this->load->model('user/attendance_model');
		$this->load->model('user/task_model');
	}

	function index($id=null)
	{
		if(isset($id))
		{
			$user= $id;
		}else
		{
			$user=$this->session->userdata('user_id');		
		}
		$data['userid'] = $user;
		$page = $this->session->flashdata('page');
		$meta['page_title'] = "welcome user";
		$meta['message'] = "Logged In Successfully";		
		$data['my_tasks'] = $this->user_model->get_my_tasks();
		$data['designationbyid'] = $this->about_model->designationbyid($user);
		
		$data['my_projects'] =  $this->task_model->my_recent_projects();
		$data['user'] = $this->about_model->get_user_details($this->session->userdata('user_id'));
		$data['coffeebyid'] = $this->about_model->coffeebyid($user);
		
		$data['fav_todos'] = $this->user_model->fav_todo();
		
		
		$data['fav_projects'] = $this->user_model->get_fav_projects();
		$data['fav_tasks'] = $this->user_model->get_fav_tasks();
		
		$data['todos'] = $this->user_model->get_today_todo();
		
		$data['more_todos'] = $this->user_model->more_todos();
		$data['todos_not_dated'] = $this->user_model->todos_not_dated();	
		
		$data['active_user'] = $this->user_model->get_active_user();
		
		
		$this->load->view('common/header', $meta);
		// $this->load->view('user / '.$page.' / dashboard',$data);
		$this->load->view('user/dashboard',$data);
		$this->load->view('common/footer');
	}
	
	function more_todos()
	{	
		$data['previous_todo'] = $this->user_model->previous_todo();
		$data['todos_not_dated'] = $this->user_model->todos_not_dated();	
		$data['more_todos'] = $this->user_model->more_todos();		
		$this->load->view('user/todo_load_more',$data);	
			
	}
	
	function insert_drinks()
	{	
		$insert['attendance_timings_id'] = $_REQUEST['id'];		
		$insert['drink'] = $_REQUEST['drink'];
		$this->user_model->insert_drinks($insert);
	}
	
	function kitchenette()
	{
		$data['get_drinks'] = $this->user_model->get_drinks();
		$data['tea'] = $this->user_model->count_tea();
		$data['coffee'] = $this->user_model->count_coffee();
		$data['soup'] = $this->user_model->count_soup();
		$meta['page_title'] = 'Fedobe kitchenette';
		$this->load->view('common/header', $meta);		
		$this->load->view('user/kitchen', $data);
		$this->load->view('common/footer');
	}
	
	function mail(){
		
		$meta['page_title'] = 'Webmail ::';
		$this->load->view('common/header', $meta);		
		$this->load->view('user/mail');
		$this->load->view('common/footer');
	}

}

?>